﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using netcoreweb.Models;

namespace netcoreweb.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Error()
        {
            return View();
        }

        [HttpGet]
        public IActionResult Test()
        {
            int hour = DateTime.Now.Hour;
            ViewBag.Greeting = hour < 12 ? "上午好" : "下午好";
            return View();
        }

        [HttpPost]
        public IActionResult Test(GuestResponse guest)
        {
            System.Console.WriteLine(guest.Name);
            return View("Thanks", guest);
        }
    }
}
